Page({
  data: {
    //查看资质窗口
    popupshow: false,
    //门店列表
    shops: [],
    //当前选择的门店下标
    shopindex: 0,
  },
  onLoad: function (options) {
    let that = this;
    //获取shop门店列表
    let shops = tt.getStorageSync("shops");
    that.setData({
      shops: shops,
    });
  },
  //拨打电话
  callPhone(event: any) {
    if (event.currentTarget.dataset.phone) {
      tt.makePhoneCall({
        phoneNumber: event.currentTarget.dataset.phone,
      });
    }
  },
  //查看资质
  checkQualif(event: any) {
    let that = this;
    that.setData({
      popupshow: true,
      shopindex: event.currentTarget.dataset.index,
    });
  },
  //关闭弹出层
  closePopup() {
    let that = this;
    that.setData({
      popupshow: false,
    });
  },
  //打开导航
  openLocation(event: any) {
    let data = event.currentTarget.dataset;
    tt.openLocation({
      latitude: data.latitude,
      longitude: data.longitude,
      name: data.name,
      address: data.address,
      scale: 18,
      success() {
        console.log("打开地图成功");
      },
      fail(err) {
        console.log("打开地图失败:", err.errMsg);
        tt.showToast({
          title: "请打开位置权限",
          icon: "fail",
          duration: 1500,
        });
        tt.openSetting({
          success: () => {
            console.log("openSetting success");
          },
        });
      },
    });
  },
});
